import {Injectable} from '@angular/core';
import {HttpClient} from '@angular/common/http';
import {Observable} from 'rxjs';
import {CommonTool} from '../common/common.tool';
import {HTTP_URLS} from '../base/base-http.url';

@Injectable({
  providedIn: 'root'
})
export class HomeService {

  constructor(private http: HttpClient,
              public commonTool: CommonTool) {

  }

  /**
   * 退出登录
   */
  public logOut(): Observable<any> {
    return this.http.delete<any>(HTTP_URLS.deleteToken);
  }


  /**
   * 修改密码
   */
  public updatePassword(req: any): Observable<any> {
    return this.http.put<any>(HTTP_URLS.updatePassword, req);
  }

  /**
   * 修改用户信息
   */
  public updateUserInfo(req): Observable<any> {
    return this.http.put<any>(HTTP_URLS.updateUserInfo, req);
  }

  /**
   * 获取用户信息
   */
  public getUserByToken(): Observable<any> {
    return this.http.get<any>(HTTP_URLS.getUserByToken);
  }

}
